package io.xccit.product.controller;

import io.xccit.model.product.domain.Product;
import io.xccit.product.service.ProductService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author CH_ywx
 * @version 1.0
 * @create 2025/5/17
 * <p></p>
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/{id}")
    public Product getProductById(@PathVariable Long id,
                                  HttpServletRequest request) {
        String header = request.getHeader("X-Token");
        System.out.println("X-Token:"+header);
        return productService.getProductById(id);
    }
}
